package com.appspot.niehonglei.action;

import javax.jdo.PersistenceManager;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.appspot.niehonglei.dao.PMF;
import com.appspot.niehonglei.jdo.Comment;

public class DeleteComment implements ActionInterface{
	public void execute(HttpServletRequest request, HttpServletResponse response) {
		String id = request.getParameter("id");
		try{
			if (id != null) {
				PersistenceManager pm = PMF.get().getPersistenceManager();
				Comment comment = pm.getObjectById(Comment.class,Long.valueOf(id));
				pm.deletePersistent(comment);
				pm.close();
				
			}
			response.sendRedirect("/comment");
		}catch(Exception e){
			e.printStackTrace();
		}
	}
}
